home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / imglib2 / ImageLogging.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  8KB  |  227 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * ***** BEGIN LICENSE BLOCK *****
  4.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5.  *
  6.  * The contents of this file are subject to the Mozilla Public License Version
  7.  * 1.1 (the "License"); you may not use this file except in compliance with
  8.  * the License. You may obtain a copy of the License at
  9.  * http://www.mozilla.org/MPL/
  10.  *
  11.  * Software distributed under the License is distributed on an "AS IS" basis,
  12.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13.  * for the specific language governing rights and limitations under the
  14.  * License.
  15.  *
  16.  * The Original Code is mozilla.org code.
  17.  *
  18.  * The Initial Developer of the Original Code is
  19.  * Netscape Communications Corporation.
  20.  * Portions created by the Initial Developer are Copyright (C) 2001
  21.  * the Initial Developer. All Rights Reserved.
  22.  *
  23.  * Contributor(s):
  24.  *   Stuart Parmenter <pavlov@netscape.com>
  25.  *
  26.  * Alternatively, the contents of this file may be used under the terms of
  27.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  28.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29.  * in which case the provisions of the GPL or the LGPL are applicable instead
  30.  * of those above. If you wish to allow use of your version of this file only
  31.  * under the terms of either the GPL or the LGPL, and not to allow others to
  32.  * use your version of this file under the terms of the MPL, indicate your
  33.  * decision by deleting the provisions above and replace them with the notice
  34.  * and other provisions required by the GPL or the LGPL. If you do not delete
  35.  * the provisions above, a recipient may use your version of this file under
  36.  * the terms of any one of the MPL, the GPL or the LGPL.
  37.  *
  38.  * ***** END LICENSE BLOCK ***** */
  39.  
  40. #include "prlog.h"
  41. #include "prinrval.h"
  42.  
  43. #include "nsString.h"
  44.  
  45. #if defined(PR_LOGGING)
  46. extern PRLogModuleInfo *gImgLog;
  47.  
  48. #define GIVE_ME_MS_NOW() PR_IntervalToMilliseconds(PR_IntervalNow())
  49.  
  50. class LogScope {
  51. public:
  52.   LogScope(PRLogModuleInfo *aLog, void *from, const nsACString &fn) :
  53.     mLog(aLog), mFrom(from), mFunc(fn)
  54.   {
  55.     PR_LOG(mLog, PR_LOG_DEBUG, ("%d [this=%p] %s {ENTER}\n",
  56.                                    GIVE_ME_MS_NOW(),
  57.                                    mFrom, mFunc.get()));
  58.   }
  59.  
  60.   /* const char * constructor */
  61.   LogScope(PRLogModuleInfo *aLog, void *from, const nsACString &fn,
  62.            const nsDependentCString ¶mName, const char *paramValue) :
  63.     mLog(aLog), mFrom(from), mFunc(fn)
  64.   {
  65.     PR_LOG(mLog, PR_LOG_DEBUG, ("%d [this=%p] %s (%s=\"%s\") {ENTER}\n",
  66.                                    GIVE_ME_MS_NOW(),
  67.                                    mFrom, mFunc.get(),
  68.                                    paramName.get(),
  69.                                    paramValue));
  70.   }
  71.  
  72.   /* void ptr constructor */
  73.   LogScope(PRLogModuleInfo *aLog, void *from, const nsACString &fn,
  74.            const nsDependentCString ¶mName, const void *paramValue) :
  75.     mLog(aLog), mFrom(from), mFunc(fn)
  76.   {
  77.     PR_LOG(mLog, PR_LOG_DEBUG, ("%d [this=%p] %s (%s=%p) {ENTER}\n",
  78.                                    GIVE_ME_MS_NOW(),
  79.                                    mFrom, mFunc.get(),
  80.                                    paramName.get(),
  81.                                    paramValue));
  82.   }
  83.  
  84.   /* PRInt32 constructor */
  85.   LogScope(PRLogModuleInfo *aLog, void *from, const nsACString &fn,
  86.            const nsDependentCString ¶mName, PRInt32 paramValue) :
  87.     mLog(aLog), mFrom(from), mFunc(fn)
  88.   {
  89.     PR_LOG(mLog, PR_LOG_DEBUG, ("%d [this=%p] %s (%s=\"%d\") {ENTER}\n",
  90.                                    GIVE_ME_MS_NOW(),
  91.                                    mFrom, mFunc.get(),
  92.                                    paramName.get(),
  93.                                    paramValue));
  94.   }
  95.  
  96.   /* PRUint32 constructor */
  97.   LogScope(PRLogModuleInfo *aLog, void *from, const nsACString &fn,
  98.            const nsDependentCString ¶mName, PRUint32 paramValue) :
  99.     mLog(aLog), mFrom(from), mFunc(fn)
  100.   {
  101.     PR_LOG(mLog, PR_LOG_DEBUG, ("%d [this=%p] %s (%s=\"%d\") {ENTER}\n",
  102.                                    GIVE_ME_MS_NOW(),
  103.                                    mFrom, mFunc.get(),
  104.                                    paramName.get(),
  105.                                    paramValue));
  106.   }
  107.  
  108.  
  109.   ~LogScope() {
  110.     PR_LOG(mLog, PR_LOG_DEBUG, ("%d [this=%p] %s {EXIT}\n",
  111.                                    GIVE_ME_MS_NOW(),
  112.                                    mFrom, mFunc.get()));
  113.   }
  114.  
  115. private:
  116.   PRLogModuleInfo *mLog;
  117.   void *mFrom;
  118.   nsCAutoString mFunc;
  119. };
  120.  
  121.  
  122. class LogFunc {
  123. public:
  124.   LogFunc(PRLogModuleInfo *aLog, void *from, const nsDependentCString &fn)
  125.   {
  126.     PR_LOG(aLog, PR_LOG_DEBUG, ("%d [this=%p] %s\n",
  127.                                 GIVE_ME_MS_NOW(), from,
  128.                                 fn.get()));
  129.   }
  130.  
  131.   LogFunc(PRLogModuleInfo *aLog, void *from, const nsDependentCString &fn,
  132.           const nsDependentCString ¶mName, const char *paramValue)
  133.   {
  134.     PR_LOG(aLog, PR_LOG_DEBUG, ("%d [this=%p] %s (%s=\"%s\")\n",
  135.                                 GIVE_ME_MS_NOW(), from,
  136.                                 fn.get(),
  137.                                 paramName.get(), paramValue));
  138.   }
  139.  
  140.   LogFunc(PRLogModuleInfo *aLog, void *from, const nsDependentCString &fn,
  141.           const nsDependentCString ¶mName, const void *paramValue)
  142.   {
  143.     PR_LOG(aLog, PR_LOG_DEBUG, ("%d [this=%p] %s (%s=\"%p\")\n",
  144.                                 GIVE_ME_MS_NOW(), from,
  145.                                 fn.get(),
  146.                                 paramName.get(), paramValue));
  147.   }
  148.  
  149.  
  150.   LogFunc(PRLogModuleInfo *aLog, void *from, const nsDependentCString &fn,
  151.           const nsDependentCString ¶mName, PRUint32 paramValue)
  152.   {
  153.     PR_LOG(aLog, PR_LOG_DEBUG, ("%d [this=%p] %s (%s=\"%d\")\n",
  154.                                 GIVE_ME_MS_NOW(), from,
  155.                                 fn.get(),
  156.                                 paramName.get(), paramValue));
  157.   }
  158.  
  159. };
  160.  
  161.  
  162. class LogMessage {
  163. public:
  164.   LogMessage(PRLogModuleInfo *aLog, void *from, const nsDependentCString &fn,
  165.              const nsDependentCString &msg)
  166.   {
  167.     PR_LOG(aLog, PR_LOG_DEBUG, ("%d [this=%p] %s -- %s\n",
  168.                                 GIVE_ME_MS_NOW(), from,
  169.                                 fn.get(),
  170.                                 msg.get()));
  171.   }
  172. };
  173.  
  174. #define LOG_SCOPE(l, s) \
  175.   LogScope LOG_SCOPE_TMP_VAR ##__LINE__ (l,                            \
  176.                                          NS_STATIC_CAST(void *, this), \
  177.                                          NS_LITERAL_CSTRING(s))
  178.  
  179. #define LOG_SCOPE_WITH_PARAM(l, s, pn, pv) \
  180.   LogScope LOG_SCOPE_TMP_VAR ##__LINE__ (l,                            \
  181.                                          NS_STATIC_CAST(void *, this), \
  182.                                          NS_LITERAL_CSTRING(s),        \
  183.                                          NS_LITERAL_CSTRING(pn), pv)
  184.  
  185. #define LOG_FUNC(l, s)                  \
  186.   LogFunc(l,                            \
  187.           NS_STATIC_CAST(void *, this), \
  188.           NS_LITERAL_CSTRING(s))
  189.  
  190. #define LOG_FUNC_WITH_PARAM(l, s, pn, pv) \
  191.   LogFunc(l,                              \
  192.           NS_STATIC_CAST(void *, this),   \
  193.           NS_LITERAL_CSTRING(s),          \
  194.           NS_LITERAL_CSTRING(pn), pv)
  195.  
  196. #define LOG_STATIC_FUNC(l, s)           \
  197.   LogFunc(l,                            \
  198.           nsnull,                       \
  199.           NS_LITERAL_CSTRING(s))
  200.  
  201. #define LOG_STATIC_FUNC_WITH_PARAM(l, s, pn, pv) \
  202.   LogFunc(l,                             \
  203.           nsnull,                        \
  204.           NS_LITERAL_CSTRING(s),         \
  205.           NS_LITERAL_CSTRING(pn), pv)
  206.  
  207.  
  208.  
  209. #define LOG_MSG(l, s, m)                   \
  210.   LogMessage(l,                            \
  211.              NS_STATIC_CAST(void *, this), \
  212.              NS_LITERAL_CSTRING(s),        \
  213.              NS_LITERAL_CSTRING(m))
  214.  
  215.  
  216. #else
  217. #define LOG_SCOPE(l, s)
  218. #define LOG_SCOPE_WITH_PARAM(l, s, pn, pv)
  219. #define LOG_FUNC(l, s)
  220. #define LOG_FUNC_WITH_PARAM(l, s, pn, pv)
  221. #define LOG_STATIC_FUNC(l, s)
  222. #define LOG_STATIC_FUNC_WITH_PARAM(l, s, pn, pv)
  223. #define LOG_MSG(l, s, m)
  224. #endif
  225.  
  226. #define LOG_MSG_WITH_PARAM LOG_FUNC_WITH_PARAM
  227.